﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using Silmoon.DNS.Monitoring.Data;
using Silmoon.Threading;

namespace Silmoon.DNS.Monitoring
{
    public class GBC : Silmoon.MySilmoon.SilmoonProductGBCInternat
    {
        public NameValueCollection Parameters = Silmoon.SmString.AnalyzeNameValue(Environment.GetCommandLineArgs(), "=", "--");
        public Configure configure = null;
        public Mongo mongo = null;
        public MonitorCollectController monitorCollectController = null;
        public Communicator communicator = null;

        public GBC()
        {
            this.OnStart += new OperateHandler(GBC_OnStart);
            this.OnStop += new OperateHandler(GBC_OnStop);
        }

        bool GBC_OnStart(bool success)
        {
            if (success)
            {
                configure = new Configure(this);
                mongo = new Mongo(this);
                monitorCollectController = new MonitorCollectController(this);
                communicator = new Communicator(this);
                mongo.OpenMongoDB();

                Threads.ExecAsync(monitorCollectController.StartA, onThreadException);

                return true;
            }
            else return false;
        }

        bool GBC_OnStop(bool success)
        {
            if (success)
            {

                return true;
            }
            else return false;
        }
    }
}
